package demo1217.pm;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/*
时间相关的类:
Date  SimpleDateFormat  Calendar
String  -->Date -->Calendar
Calendar-->Date -->String

String  -->Date -->Calendar
步骤:
1.String s = "2020-10-1"
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  Date date = sdf.parse(s);
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);

2.Calendar-->Date -->String
  Calendar cal = Calendar.getInstance();
  Date date = cal.getTime();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  String time = sdf.format(date);
 */
public class Demo_03 {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        Date date = cal.getTime();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String time = sdf.format(date);

        System.out.println(time);
    }
}
